package com.apes.fn.scm.prepare.model;

import com.apes.framework.jpa.DefaultPersistListener;
import com.apes.framework.jpa.Model;
import com.apes.framework.jpa.comment.Comment;
import com.apes.framework.jpa.generator.ApesGenerator;
import com.apes.framework.util.ApesConst;
import com.apes.scm.masterdata.enumeration.model.Enumeration;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.SelectBeforeUpdate;

import javax.persistence.*;

/**
 * 待缴款单
 * <p>
 * mut
 */
@Getter
@Setter
@SelectBeforeUpdate
@DynamicInsert
@DynamicUpdate
@Entity
@EntityListeners(DefaultPersistListener.class)
@Table(name = ToPrepareDetail.CONST_TABLE_NAME)
public class ToPrepareDetail extends Model {
    public static final String CONST_TABLE_NAME = "mas_to_prepare_detail";


    @Id
    @Column(name = "id")
    @ApesGenerator(code = CONST_TABLE_NAME, name = "编号", padding = 5)
    @Comment("编码")
    private String id;  //编码

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "payment_type", referencedColumnName = "id")
    @Comment("收款类型")
    private Enumeration paymentType;

    @Column(name = "amount", nullable = false, columnDefinition = ApesConst.FIELD_QTY_16_4_0)
    @Comment("收款金额")
    private double amount = 0.0;

    @Column(name = "source", length = 30)
    @Comment("来源单据")
    private String source;

    @Column(name = "source_business_type", length = 32)
    @Comment("来源单据类型")
    private String sourceBusinessType;

    @Column(name = "note")
    @Comment("备注")
    private String note;

    @Column(name = "record")
    @Comment("到账记录")
    private String record;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "mas_to_prepare_id", referencedColumnName = "id")
    @Comment("代缴款单")
    private ToPrepare toPrepare;
}
